
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Mr Bao
 */
public class ListImageName extends List implements Runnable, CommandListener {

    private boolean isRunning = true;
    private HomeScreen homeScreen;
    private Command cmdBack = new Command("Back", Command.BACK, 2);

    public ListImageName(HomeScreen homeScreen) {
        super("UpAnh", IMPLICIT);
        this.homeScreen = homeScreen;
        addCommand(cmdBack);
        setCommandListener(this);
        new Thread(this).start();
    }

    public void run() {
        while (isRunning) {
            if (Common.Client.lstImageNames == null) {
                isRunning = false;
            } else if (Common.Client.lstImageNames.size() > 0) {
                this.append(Common.Client.lstImageNames.elementAt(0).toString(), null);
                Common.Client.lstImageNames.removeElementAt(0);
            }
            System.gc();
        }
    }

    public void commandAction(Command c, Displayable d) {
        if (c == cmdBack) {
            homeScreen.DisplayViewAlbumFormBack();
        } else if (c == SELECT_COMMAND) {
            Common.Client.ViewImage(getSelectedIndex());
            homeScreen.DisplayViewImageForm();
        }
    }
}
